* Apply to:  sfmay_2018.xls
* Description:  Table 2

clear


import excel "...\2204 JEPS\sfmay_2018.xls", sheet("Sheet1") firstrow


* Spatial voting

* Candidate ideal points

* Breed       1.00
* Greenberg   1.87
* Kim        -1.00
* Leno       -0.73

gen head1_correct = 0
replace head1_correct = 1 if d1<=1.435 & head1_choice==1
replace head1_correct = 1 if d1>=1.435 & head1_choice==2
replace head1_correct = . if head1_choice==.

gen head2_correct = 0
replace head2_correct = 1 if d1>=0 & head2_choice==1
replace head2_correct = 1 if d1<=0 & head2_choice==2
replace head2_correct = . if head2_choice==.

gen head3_correct = 0
replace head3_correct = 1 if d1>=0.135 & head3_choice==1
replace head3_correct = 1 if d1<=0.135 & head3_choice==2
replace head3_correct = . if head3_choice==.

gen head4_correct = 0
replace head4_correct = 1 if d1>=0.435 & head4_choice==1
replace head4_correct = 1 if d1<=0.435 & head4_choice==2
replace head4_correct = . if head4_choice==.

gen head5_correct = 0
replace head5_correct = 1 if d1>=0.57 & head5_choice==1
replace head5_correct = 1 if d1<=0.57 & head5_choice==2
replace head5_correct = . if head5_choice==.

gen head6_correct = 0
replace head6_correct = 1 if d1<=-0.865 & head6_choice==1
replace head6_correct = 1 if d1>=-0.865 & head6_choice==2
replace head6_correct = . if head6_choice==.


* Stack head-to-head matchups (6 per respondent)

sort id

expand 6

sort id

by id: gen head = [_n]


* Head-to-head matchups

* 1. Breed vs. Greenberg
* 2. Breed vs. Kim
* 3. Breed vs. Leno
* 4. Greenberg vs. Kim
* 5. Greenberg vs. Leno
* 6. Kim vs. Leno

* Vote for more proximate (correct) alternative

gen vote_spatial = 0
replace vote_spatial = head1_correct if head==1
replace vote_spatial = head2_correct if head==2
replace vote_spatial = head3_correct if head==3
replace vote_spatial = head4_correct if head==4
replace vote_spatial = head5_correct if head==5
replace vote_spatial = head6_correct if head==6


* Drop party cue, voter guide treatment groups

drop if treatment1==2 | treatment1==3 | treatment1==4


* IV Estimator (assignment to information choice treatment group)

gen treatment3 = 0
replace treatment3 = 1 if treatment1==5


* Choose to Receive Information

gen info_choice2 = 0
replace info_choice2 = 1 if treatment2==7 | treatment2==8


* Table 2.  Instrumental Variable Estimate of Local Average Treatment Effect

ivregress 2sls vote_spatial (info_choice2 = treatment3)


* End